On the digiMatic diskette, you will find two files; Test Data.PICT and Test Data.PAINT. Copy one of them to your hard disk. Open the file by using your favorite painting or drawing program, respectively. You will see the following graph (yours will be a little bit bigger...).
 
This data was "made up" so that we would know the exact values of X and Y that the data represent. We are going to compare them to the values that digiMatic calculates from mouse clicks on the screen.
You should have your version of this graph open on your computer. Follow along.
1. Start up the digiMatic application. Click the Options button and choose the crosshair cursor, Save Text in landscape style, and Play As points options. Click the Save button in the Options dialog to save your choices.
2. Click the X Axis button (1-X) to bring up the X Axis dialog. If the dialog box obscures the view of either the top left corner or bottom right corner of your graph, option-click and drag the dialog box to a better location. Enter 0 for the X Min value and 30 for the X Max value. Move the mouse so that the cursor lines up on the X Axis value of 30 on the graph image and click once to set the screen coordinates of the X Max value.
3. Click the Y Axis button in the bottom right of the X Axis dialog to bring up the Y Axis dialog. Enter 0 for the Y Min value and 30 for the Y Max value. Move the mouse and line up the crosshair cursor over the Y Axis value of 30 on the graph image and click once to set the screen coordinates of the Y Max value. Click OK to exit the Y Axis dialog. Feel free to start over from any point if you %$#&-@$.
4. Click the Options button again and choose the bullseye cursor. Click Save to save this choice and exit the dialog.
5. Click the Mouse Record button. Center the bullseye over each data point on the graph image and click once. You should hear an audible "shwick" each time you record a point. Don't worry about the order in which you click the points. You can reorder them later.
6. When you think you have them all, click the Play button on the Record box. Look for a "reverse image" dot (i.e., black goes to white and vice versa) to appear on each data point you have clicked. Note the location of any missed points. Click the mouse to make the playback image go away and click in any points you have missed.
7. Click the Edit button in the Record box. You should have 25 points recorded. Click the Sort X button in the Editor and the data will reorder in increasing X. Click the Done button in the Editor and then the Stop button in the Record box. Click the Save button in the Main Control box and save your text file to disk. Click the digiMatic go-away box to quit the program.
8. You may now use a spreadsheet, word processor, or graphing program to open this text file. We prefer to use KaleidagraphΓäó to draw Famous Engineer Technical Graphs and Other Highly Scientifilogical Illustrations. You use what you like best. The original set of numbers used to make the Test Data image are given below:
# X Y # X Y
1 1.00 0.235 14 14.00 15.022
2 2.00 0.897 15 15.00 12.359
3 3.00 1.413 16 16.00 17.322
4 4.00 1.704 17 17.00 18.952
5 5.00 2.685 18 18.00 19.988
6 6.00 4.953 19 19.00 22.354
7 7.00 8.502 20 20.00 23.005
8 8.00 7.632 21 21.00 21.569
9 9.00 10.256 22 22.00 21.852
10 10.00 12.588 23 23.00 23.844
11 11.00 14.356 24 24.00 24.000
12 12.00 12.054 25 25.00 28.963
13 13.00 15.875
Our own Famous Engineer effort to digitize the image resulted in the comparison of X and Y values to the originals shown on the following charts. The best accuracy results from digitizing as large an image as possible on the screen. The resolution on a full page monitor, for example, will be about 1 part in 640 in the X direction and about 1 part in 860 in the Y direction since a full page screen has a pixel resolution of 640 x 860. It is unlikely that any printed graph you come across can be read or copied with better accuracy than this and your points are probably as accurate as you will need.
We've plotted the absolute and percentage errors for the values we obtained after digitizing the Test Data example:
 
 
Notice that the absolute errors are small with Y errors tending towards a mean of about +0.06 and the X errors are either zero or about -0.05. There were two sources of error in this exercise. First, the graphing program used to create the image can't place points exactly where they are supposed to go since the placement is at the mercy of a fixed number of placement points (pixels) on the screen. The points are placed over the "best" (nearest) pixel.
With this on-screen image, digiMatic was working under the same limitation. Even though we hit dead bullseye with the cursor when digitizing, we were not always precisely on the point (since the graphing program couldn't place it there, see?). It stands to reason that you will sometimes hit dead on (zero error), sometimes be a fraction of a pixel high, and sometimes be a fraction of a pixel low. Over a sufficient number of points, the average error will tend to be about a half pixel (either high or low) about half of the time (notice the X data errors).
Numerically, the absolute error will be approximately (0.5 pixels/length of the axis in pixels) times the (numerical "length") of the axis. For example, when we digitized the screen coordinates of the axes of our Test Data image, we found that the X axis was about 315 pixels long and the Y axis was about 250 pixels long (your's should be about 250 x 180, respectively). Our X errors should be about (0.5/315) * 30 = .048 and our Y error should be about (0.5/250) * 30 = 0.060.
This table shows the values of the absolute errors we obtained:
# X Error Y Error # X Error Y Error
1 -.050 0.092 14 0.000 0.022
2 0.000 0.040 15 -.048 0.073
3 -.048 0.127 16 0.000 0.036
4 0.000 0.133 17 -.048 0.095
5 -.048 0.114 18 0.000 -0.002
6 0.000 0.096 19 -.048 0.068
7 -.048 0.073 20 0.000 0.005
8 0.000 0.061 21 -.048 -0.002
9 -.048 0.113 22 0.000 -0.005
10 0.000 0.017 23 -.048 -0.013
11 -.048 0.070 24 0.000 0.000
12 0.000 0.054 25 -.048 0.106
13 -.048 0.018
The X errors are either zero or 0.048 (in this case to the negative side) and the Y errors average 0.057. (Somebody do an F-test for 25 observations and see if this is the same as 0.060...). We don't have a good explanation for why the Y errors don't alternate the way that the X errors do. Maybe this has to do with the way our graphing program "rounds" values for placement on the picture it creates.
Now, look at the graph of the percentage errors. As you might expect, the same absolute error gets magnified in effect when percentage errors are calculated. Larger percentage errors will be obtained at smaller values of X and Y and then decrease as the numerical values increase. The only way to beat this problem would be to use a graph of only the data near the origin. In effect, this "expands the grid" for digitizing in that region. Any graph you might obtain from technical literature will give the same type of result. You can only "read" any given point to a certain accuracy ΓÇö the percent error will be magnified as the numbers you "read" or digitize get smaller. This is true whether you "read" the points with a ruler, with digiMatic , or with some highly scientifilogical laser beam farbulator. It's just one of life's little limitations...
Tutorial 2: Advanced digiMatic ΓÇö AutoScan Mode
The image below was scanned from a facsimile. It is the infrared spectrum of poly(methyl methacrylate). (Plexiglas -- remember?)
 
The image will be rotated on your screen because it was purposely scanned while a bit askew. We have edited the values on the ordinate and abscissa for clarity, but we left all of the other normally distorted text and spurious smudges on the image to illustrate how the scanned image might actually appear on your monitor. Also, we reduced the size of the image so it could be used in the tutorial. In practice, the image could be much larger on your monitor.
Our objective will be to digitize this spectrum and obtain a very clean printout suitable for publication or inclusion in a technical report. You will note that the X axis scale comprises two different linear scales; one between 500 and 2000 cm–¡, the other between 2000 and 4000 cm–¡. We will have to handle this unusual X axis scale by defining our X axis in two parts.
1) First, open the IR.PICT or IR.PAINT image from the digiMatic diskette into a drawing or painting program, respectively. Start digiMatic . Click the Set button and choose the options shown below. Click the Save button to return to the Main Control box.
 
2) We will work first with the data from 2000-4000 cm–¡. Click the X Axis button and define X Min = 4000 and X Max = 2000 (that's right ... X Min is a bigger number than X Max in this case). Set the precision to 4 and click the X Max position at the 2000 tick mark on the X axis. Click the Y Axis button, enter Y Min = 0.0 and Y Max = 1.0 and click on the 1.0 tick mark on the Y axis. Now, unclick the Auto Origin button (if it is x'd) and click the Set Origin button. Click the intersection of the two axes at the (0,4000) location — this establishes the origin so that the unrotate algorithm can do its job. Click the OK button and return to the Main Control box.
3) Click the AutoScan Record mode button. Immediately, you will see the image change so that just the portion of the image you need to work with appears on the screen. This is the special screen capture at work. The AutoScan Record tools will also appear on your monitor. Click the Eraser button and erase the peak in the image and a bit of the axes just around the point where the spectrum hits the Y axis. Your partially cleaned up image will look something like the one below (we're showing you part of a larger image we actually scanned). Click the Save button to retain the partially cleaned up image in case you make a mistake and wish to begin again without having to do this cleanup job a second time. Notice that it is not necessary to erase all the other garbage in the image. We got rid of just enough to be able to cleanly lasso the part of the image we want to AutoScan.
 
4) Click the Lasso tool and lasso around the remaining part of the spectrum. As with painting programs, releasing the mouse button before closing the lasso results in the lasso closing itself from your current position to whereever you started the lasso. Click the Scan button. When the scan is finished, click the Stop button and return to the Main Control box. The image reverts to the unerased image and the points you recorded are retained in memory as the first data set.
5) We will complete this part of the spectrum using Mouse Record mode to digitize the peak. Click the Mouse Record mode button. We do not redefine the coordinate system since we are still working with the 2000-4000 cm–¡ part of the spectrum. Answer Yes to the alert box that appears since we want to add more points to the current curve. The Mouse Record mode box appears. Use the command keys (1 -1,2,3, or 4) to change the cursor if you don't like the one that first appears.
Beginning on the left of the peak at ~3000 cm–¡, click along the peak and record enough points to define the peak. Every 1/4 to 1/2 inch along the peak path should be sufficient but you will want to click all locations where the slope abruptly changes. We clicked about 14 points (5 were at the peaks and valleys). When you are finished, click Stop and return to the Main Control box.
6) Now, click the Edit button and the Editor appears. Click the Sort X button. The data will be sorted by X value so that the values you recorded for the peak are positioned properly in the data set. The sort will be in ascending order so the points starting around 2000 cm–¡ will come first in the sorted data set. Click the Done button and return to the Main Control box.
7) You may either save this data set to disk (click the Save button), or, if you have a graphics program running also, you may use the menu or 1-C to copy the data to the clipboard and then paste it into your graphics program and save the data to disk there. Save the data somewhere though ΓÇö unless, of course, your Mac is the one that never crashes that we read about in the Apple manual.
8) Next, click on your drawing or painting program and construct a "Y axis" at the 2000 cm–¡ tick remembering to keep your new axis at right angles to the X Axis. We constructed a small rectangle and then rotated it so the top of the rectangle was parallel to the X axis first. Then, we used the rotated rectangle to help us construct a) the new Y axis and b) the new 1.0 tick mark location for Y Max. Your image should look something like the image below.
 
9) Redefine the X Axis and Y Axis coordinates as you did in Step (2) using X Min = 2000 and X Max = 500 this time. Use AutoScan Record mode to digitize the relatively flat portions of the spectrum if you want to retain some of the detail (i.e., the portion just left of 1500 cm–¡ and just left of 500 cm–¡. After erasing, your image should resemble the one below. We're showing you the image just after lassoing the portion to be AutoScanned.
 
10) As before, scan the image and click Stop to return to the Main Control box.. Enter Mouse Record mode, clicking Yes to the alert, and digitize the peaks. Click in order Stop, Edit, Sort X, Done. Finally, Save or copy and paste your data.
We imported our data sets into Kaleidagraph and reconstructed the spectrum in two parts using "line" graphs and interpolated "fits". Each part had to be plotted with increasing X values to the right of the graph instead of the left. We copied the graphs from KaleidagraphΓäó into MacDraw IIΓäó, deleted the objects we didn't need (like axis labels), and then flipped the images horizontally. We then grouped the spectral images together so that increasing X values were on the left and relabeled the drawing. The resulting spectrum is shown below. You might like to frame it or, perhaps, give it to a loved one! Nice job!!
 
Tutorial 3: For Business Executives
Whoa! The latest Apple stock prices were copied from MacWeek and an overhead transparency was made for a Business Executive (Business Executives don't know how to work scanners...). We cleaned up the text just a bit for legibility. The data needed to be recovered and replotted as a bar chart so the Business Executive could use it at the next bored ...er, board meeting. Precision isn't a necessity here (Business Executives just need "the big picture"), so plaster that transparency on the screen and eyeball in the axis clicks.
 
(1) Start up digiMatic using a blank screen in a drawing or painting program as a backdrop. Alternatively, Business Executives might have to use the control panel to make their Finder screen white since they only have financial analysis packages and TetrisΓäó on their Macs. Define X Min = 0 and X Max = 13 (the number of weeks covered). Set Y Min = 46.0 and Y Max = 70.0. Remember to click the origin since the graph is rotated on the monitor (Business Executives always want things straight...). Record points at each week using Mouse Record.
2) It may be difficult to click on points at exact intervals of X. Don't try ΓÇö just get as close as possible to the correct Y values in a reasonable vicinity of the correct X value. We'll fix the X values in the Editor.
3) Click Stop, then click Edit. Click Sort X if needed and then set the X data precision to 0. Your X values will round to the proper integer values. If the first X data value is between 0 and 1, it will round to a single decimal. Click this point and use the editing box to change this value to exactly 1. Your X values should be 1-13 when finished. Click Done to exit the Editor. Save the data and import it into a spreadsheet or graphics package for replotting. Insert a column for new X data and enter the weeks corresponding to 1-13 on the X axis you recorded. The final plot used at the meeting is shown below.
 
Tutorial 4: For Programmers Only
This problem is primarily for programmers but others (like artists and
designers) might also try the digitizing exercise since it will probably lead to some nifty ideas on using digiMatic . On your digiMatic diskette, find the files named Torso.PICT and Torso.PAINT. Again, copy one of them to your disk and open the appropriate one into your favorite drawing or painting application. Here is what you will see...
 
This picture is part of a screen captured during a session with ResEdit. The programmer is developing a resource that will display a picture of the torso and allow the user to click on various parts of the body ("regions" of the diagram in the venacular). The programmer must code in a set of screen coordinate values to tell the machine exactly where to draw this window when it pops up. We have already described how to use digiMatic to find the values of the screen coordinates that define window locations. The programmer can use these values in the appropriate resource dialog in ResEdit when the resource is defined.
A much more tedious problem is defining the screen locations of the various regions of the torso that the user will click to get some information about that part. This is done by defining a set of coordinate values relative to the window (or "local" coordinates as those in the know call them...) for each region. Programmers who have mapped something like this before will attest to the tedium and frustration involved. digiMatic just simplified your life immeasurably, folks!
To map the torso regions, you would open the DITL resource as shown below. The torso picture will necessarily be the same size as it will appear on the screen later (the programmers will know why...the rest of you trust me). Bring up digiMatic and refer to the resource drawing.
1. Click the X Axis button and define the X Min = 0 and X Max = (window width in pixels). In this example, the window width is 139 pixels ΓÇö obtain this value from the window definition coordinates. Place the digiMatic crosshair cursor to intersect the bottom right corner of the torso window and click the mouse.
2. Click the Y Axis button. Declare Y Max = 0 and Y Min = (window height in pixels). In this problem, the height is 191 pixels. Mouse the crosshair to intersect the top left corner of the window outline and click the mouse. Click the OK button.
 
3. Click the Record button and digitize the region filled in gray on your screen image. Treat the boundary as a closed polygon. Curved sections are made to look like curves by connecting several short lines together. Programmers will be aware that the last point does not have to exactly reproduce the first. The polygon will "close itself" in the code.
The values we obtained for this region are:
X Axis Y Axis
104 133
108 127
95 124
90 124
84 105
94 97
103 125
103 133
The following C code is an example of how you would use the coordinates in an application.
RgnHandle defineBodyPart( ) /* */
{
RgnHandle myBodyPart;
myBodyPart = 0L;
myBodyPart = NewRgn( ); /* Allocate a new region (your code
should do error checking) */
OpenRgn( ); /* Open the region for defining*/
MoveTo (104,133); /* Now use the recorded values! */
LineTo (101,127);
LineTo (95,124);
LineTo (90,124);
LineTo (84,105);
LineTo (94,97);
LineTo (103,125);
LineTo (103,133);
CloseRgn( myBodyPart); /* Close the region */
return( myBodyPart); /* Return the new handle*/
}
4. You can now use toolbox routines like PtInRgn and InvertRgn to create different effects when the user clicks in this region.
Tutorial 5: Areas of Closed Curves
Joe Bob Ledbetter, an employee of the Department of Transportation, was asked by his supervisor to report how many square miles of land area are enclosed by the major highways connecting Richmond, Charlottesville, Culpeper, and Fredericksburg, Virginia. His supervisor figured to keep Joe Bob busy the rest of the day and out of trouble. After a bit of thought, Joe Bob copied a section of his road map of Virginia along with the scale and then scanned the image into his Mac and imported it into SuperPaintΓäó. It looked sort of like the image below.
 
He then erased around the image following the curves formed by the highways connecting the cities. He also used the map scale line to form a square having the scale length on each side. He filled both the map and scaling square completely with black pixels and used the selection rectangle to "chop" the map image up just a bit. (Joe Bob sliced the image up so that each piece would have less than the 1500 point/curve maximum allowed in AutoScan mode.) He then selected the map pieces and the scaling square and reduced the size of his images with the Scale Selection command in SuperPaint.
Next, he started digiMatic and selected the option for AutoScanning all pixels in a selection. Using AutoScan Record mode, he scanned the 4 sections of his image and jotted down the number of pixels in each section. He added the pixels for the three map sections together and estimated the land area according to the formula shown beneath the picture of his final image. He reported 2443 square miles to his supervisor and took the afternoon off. Joe Bob always was a clever old boy!
 
Other Examples We Could Have Done
1) We thought up lots of highly scientifilogical examples. For instance, we could have used digiMatic to estimate the amount of icky stuff growing in a Petri dish. One might take a photograph of a Petri dish with icky stuff growing in it and one without icky stuff growing in it. Both would be scanned. A given area of each image would be AutoScanned and the second count (a "background" count) would be subracted from the first. Fortunately, we didn't have any Petri dishes with icky stuff growing in them.
2) We could have estimated the perimeter around an odd shaped closed curve by using digiMatic to count the pixels around the curve and comparing that to the number in a line segment of known length. Unfortunately, we couldn't think of a good reason to do that but Joe Bob thought he might use the idea to estimate distances on his map of Virginia.
3) We thought about splitting a closed curve into an upper part and a lower part and then using digiMatic to AutoScan the two curves and calculate the area under each curve using Simpson's Rule. The area inside the closed curve would be found as the difference between the area under the upper curve and the area under the lower curve. But Joe Bob called and we forgot to finish the problem.
4) We were going to include an example showing how to calculate the areas under chromatogram peaks but the chemicals on the GC scan we got were yucky so we didn't.
Maybe you've found a unique use for digiMatic ! If so, call and tell us about it. Or, if you're trying to something new with digiMatic and can't quite figure out how to make it work, call and maybe we can help you. The number is 804-222-2215. Oh, and if we aren't here, we probably won't be able to answer your question when you call.